package com.api.provider;

import com.api.apicommon.model.dto.UserAuth;
import com.api.apicommon.server.InnerUserService;
import com.api.model.domain.User;
import com.api.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class InnerUserServiceImpl implements InnerUserService {
    @Autowired
    private UserService userService;


    @Override
    public UserAuth getUserAuth(String userAccount, String accessKey) {
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("userAccount", userAccount).eq("accessKey", accessKey);
        User user = userService.getOne(userQueryWrapper);
        if (user == null) {
            return null;
        }
        return new UserAuth(user.getId(), user.getUserName(), user.getAccessKey(), user.getSecretKey());

    }


}
